<template>
    <el-dialog title="终止项目" :close-on-click-modal="false" append-to-body :visible.sync="visible" lock-scroll
        width="600px">
        <el-form ref="elForm" :model="dataForm" label-width="100px" label-position="right" :rules="rulesPro"
            class="commentContent">
            <template v-if="!loading">
                <el-col :span="24">
                    <el-form-item label="终止原因" prop="cancelReason">
                        <el-input v-model="dataForm.cancelReason" placeholder="请输入终止原因" />
                    </el-form-item>
                </el-col>
                <el-col :span="24" v-if="dataFormList.status > 4">
                    <el-form-item label="是否通知">
                        <el-radio-group v-model="dataForm.isNotify" @input="updateRadio">
                            <el-radio :label="false">否</el-radio>
                            <el-radio :label="true">是</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="24" v-if="dataForm.isNotify == true">
                    <el-form-item label="公告预览" v-if="dataForm.isNotify == true">
                        <el-input v-model="dataForm.message" placeholder="请输入公告" maxlength="255" type="textarea"
                            :autosize="{ minRows: 4 }" />
                        <!-- <EditorPlus :min-height="256" v-model="dataForm.message" :autoSave="false" ref="EditorPlus" /> -->
                    </el-form-item>
                </el-col>
            </template>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="terminationItem" type="primary">提交</el-button>
        </span>
    </el-dialog>
</template>
<script>
import { projectCancel } from "@/api/contract/contractOrg";
export default {
    props: {
        dataFormList: {
            type: Object,
            default: {},
        }
    },
    data() {
        return {
            visible: false,
            detailVisible: false,
            loading: false,
            textRich: '',
            dataForm: {
                isNotify: false,
                message: ''
            },
            rulesPro: {
                cancelReason: [
                    {
                        required: true,
                        message: '终止原因不能为空',
                        trigger: 'blur'
                    }
                ],
            }
        };
    },
    computed: {},
    watch: {},
    created() { },
    mounted() { },
    methods: {
        init(id) {
            this.dataForm.projectId = id || 0;
            this.visible = true;
            this.dataForm.isNotify = false
        },
        // 终止项目
        terminationItem() {
            this.$refs['elForm'].validate((valid) => {
                if (valid) {
                    projectCancel(this.dataForm).then(res => {
                        this.$emit('refreshAllCancelDio')
                    })
                }
            })

        },
        updateRadio(old) {
            this.dataForm.message = ""
        }
    },
};
</script>

<!-- <style lang="scss" scoped>
::v-deep .commentContent textarea {
    display: none;
}
</style> -->